﻿using System;
using System.Runtime.InteropServices;
using System.IO;

namespace Primer
{
    [StructLayout(LayoutKind.Sequential)]
    public struct SInteger
    {
        private static readonly SInteger s_bnMinInt;
        private static readonly SInteger _zeroInteger = new SInteger(0);
        private int _sign;
        private uint[] _bits;

        public SInteger(int value)
        {
            if (value == -2147483648)
            {
                this = s_bnMinInt;
            }
            else
            {
                _sign = value;
                _bits = null;
            }
        }

        public SInteger(uint value)
        {
            if (value <= 0x7fffffff)
            {
                _sign = (int)value;
                _bits = null;
            }
            else
            {
                _sign = 1;
                _bits = new uint[] { value };
            }
        }

        //public SInteger(StreamReader value)
        //{
        //}

        public static SInteger Zero
        {
            get { return _zeroInteger; }
        }
    }
}
